package com.cazor.dgjq.service;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.cazor.dgjq.domain.DgjqDeviceSensor;
import com.cazor.mg.domain.MgDeviceGroup;
import com.cazor.mg.service.IMgDeviceGroupService;
import lombok.Getter;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Component
public class DgJqCommonService {

    @Resource
    private IMgDeviceGroupService mgDeviceGroupService;
    @Resource
    private IDgjqDeviceSensorService dgjqDeviceSensorService;

    //546	阴洼山断裂带_X1
    //547	阴洼山断裂带_X2
    //548	阴洼山断裂带_X3
    //549	阴洼山断裂带_X4
    //550	新民堡断裂带_X1
    //551	新民堡断裂带_X2
    //552	新民堡断裂带_X3
    //553	新民堡断裂带_X4
    @Getter
    private final List<Long> ids = ListUtil.list(false, 546L, 547L, 548L, 549L, 550L, 551L, 552L, 553L);

    /**
     * 获取截面的数据列表
     * @return
     */
    public List<MgDeviceGroup> getGroupList(){
        return mgDeviceGroupService.listByIds(ids);
    }

    /**
     * 获取传感器数据列表
     * @return list
     */
    public List<DgjqDeviceSensor> getSensorList(String contentName){
        if (StrUtil.isBlank(contentName)) {
            return dgjqDeviceSensorService.list();
        } else {
            return dgjqDeviceSensorService.lambdaQuery()
                    .likeLeft(DgjqDeviceSensor::getContentName, contentName)
                    .list();
        }
    }

    /**
     * 获取地震仪数据列表
     * @return 列表
     */
    public List<DgjqDeviceSensor> getDzyList(){
        List<DgjqDeviceSensor> rtnList = new ArrayList<>();
        // DVI2312217302710	地震烈度仪-1
        // DVI3510572981202	地震烈度仪-2
        DgjqDeviceSensor sensor = new DgjqDeviceSensor();
        sensor.setSensorId("DVI2312217302710");
        sensor.setName("地震烈度仪-1");
        rtnList.add(sensor);

        sensor = new DgjqDeviceSensor();
        sensor.setSensorId("DVI3510572981202");
        sensor.setName("地震烈度仪-2");
        rtnList.add(sensor);

        return rtnList;
    }
}
